package org.gdstash.ui.table;

import org.gdstash.util.GDMsgFormatter;

import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.MouseEvent;

public class GDItemSimilarTableHeader extends JTableHeader {
    public static String[] toolTips;

    public GDItemSimilarTableHeader(final TableColumnModel columnModel) {
        super(columnModel);
    }

    static {
        GDItemSimilarTableHeader.toolTips = null;
        updateToolTips();
    }

    public static void updateToolTips() {
        if (GDItemSimilarTableHeader.toolTips == null) {
            GDItemSimilarTableHeader.toolTips = new String[6];
        }
        GDItemSimilarTableHeader.toolTips[0] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_NUM_ITEM");
        GDItemSimilarTableHeader.toolTips[1] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_NUM_ITEM_CLASS");
        GDItemSimilarTableHeader.toolTips[2] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_NUM_PREFIX");
        GDItemSimilarTableHeader.toolTips[3] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_LEVEL_PREFIX");
        GDItemSimilarTableHeader.toolTips[4] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_NUM_SUFFIX");
        GDItemSimilarTableHeader.toolTips[5] = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_LEVEL_SUFFIX");
    }

    @Override
    public String getToolTipText(final MouseEvent e) {
        final Point p = e.getPoint();
        final int index = this.columnModel.getColumnIndexAtX(p.x);
        final int realIndex = this.columnModel.getColumn(index).getModelIndex();
        return GDItemSimilarTableHeader.toolTips[realIndex];
    }
}
